//----
// PART I - Partnership Trends


	/* This file uses publicly available SOI data to 
	describe trends in partnerships over time, and
	produces Figure 3 in the paper. */

	// Read in SOI data
	
		import delimited ${oth_dir}/soi_net_income_table.csv, clear
		
	// Deflate by gdp	
	
		foreach v of varlist all_corp_net_inc-total_net_inc {
			replace `v' = `v'*gdp_deflator
			replace `v' = `v'/1e9
			}

	// Growth in net income
		
		foreach z in "ccorp" "scorp" "pshp" "sole" {
			g n_index_`z' = .
			sum `z'_net_inc if year==1996
			replace n_index_`z' = `z'_net_inc/r(mean)*100 
			}
	
	//-------
	// Figure 3

	// Grayscale
		
		twoway ///
			(connected n_index_pshp y, lwidth(mthick) color(gray*2) ms(c)) ///
			(connected n_index_scorp y, lwidth(mthick) color(gray*1) ms(d)) ///
			(connected n_index_sole y, lwidth(mthick) color(gray*.75) ms(s)) ///
			(connected n_index_ccorp y, lwidth(mthick) color(gray*.45) ms(oh)) ///
			, plotregion(lcolor(black)) ///
			graphregion(fcolor(white) lcolor(white)) ///
			bgcolor(white) ///
			xtitle("") ///
			xlabel(1996(3)2017, labsize(medsmall)) ///
			leg(pos(6) cols(2) order (1 "Partnerships" 2 "S-Corporations" 3 "Sole Proprietors" 4 "C- and Other Corporations")  size(medlarge) region(lcolor(white)))	
			graph export ${fig_dir}/fig_soi_netincome.png, replace width(1000)		
	
	// Color
		
		twoway ///
			(line n_index_pshp y, lwidth(thick) color("133 41 40")) ///
			(line n_index_scorp y, lwidth(thick) color(navy*.8)) ///
			(line n_index_sole y, lwidth(thick) color("209 145 48")) ///
			(line n_index_ccorp y, lwidth(thick) color("121 168 108")) ///
			, plotregion(lcolor(black)) ///
			graphregion(fcolor(white) lcolor(white)) ///
			bgcolor(white) ///
			xtitle("") ///
			xlabel(1996(3)2017, labsize(medsmall)) ///
			leg(pos(6) cols(2) order (1 "Partnerships" 2 "S-Corporations" 3 "Sole Proprietors" 4 "C- and Other Corporations")  size(medlarge) region(lcolor(white)))	
			graph export ${fig_dir}/fig_soi_netincome_color.png, replace width(1000)		
	

	// Share in partnership
		
		
		// Calculate shares
	
		foreach z in "ccorp" "scorp" "pshp" "sole" {
			g share_`z' = `z'_net/total_net_inc*100
			}
	
	// Grayscale
	
		twoway ///
			(connected share_pshp y, lwidth(mthick) color(gray*2) ms(c)) ///
			(connected share_scorp y, lwidth(mthick) color(gray*1) ms(d)) ///
			(connected share_sole y, lwidth(mthick) color(gray*.75) ms(s)) ///
			(connected share_ccorp y, lwidth(mthick) color(gray*.45) ms(oh)) ///
			, plotregion(lcolor(black)) ///
			graphregion(fcolor(white) lcolor(white)) ///
			bgcolor(white) ///
			xtitle("") ///
			xlabel(1996(3)2017, labsize(medsmall)) ///
			leg(pos(6) cols(2) order (1 "Partnerships" 2 "S-Corporations" 3 "Sole Proprietors" 4 "C- and Other Corporations")  size(medlarge) region(lcolor(white)))	
			graph export ${fig_dir}/fig_soi_sharenet.png, replace width(1000)		
	
	// Color
		
		twoway ///
			(line share_pshp y, lwidth(thick) color("133 41 40")) ///
			(line share_scorp y, lwidth(thick) color(navy*.8)) ///
			(line share_sole y, lwidth(thick) color("209 145 48")) ///
			(line share_ccorp y, lwidth(thick) color("121 168 108")) ///
			, plotregion(lcolor(black)) ///
			graphregion(fcolor(white) lcolor(white)) ///
			bgcolor(white) ///
			xtitle("") ///
			xlabel(1996(3)2017, labsize(medsmall)) ///
			leg(pos(6) cols(2) order (1 "Partnerships" 2 "S-Corporations" 3 "Sole Proprietors" 4 "C- and Other Corporations")  size(medlarge) region(lcolor(white)))	
			graph export ${fig_dir}/fig_soi_sharenet_color.png, replace width(1000)		
	
	
